let jwt = require('jsonwebtoken')

// let getUser = async ctx =>{
//     let sql = `select * from users`
//     ctx.body = await ctx.db.execute(sql)
//     // console.log(sql);
// }
// let getQuyu = async ctx=>{
//     // let sql = `select * from quyu2 where quyu2.areaId=1`
//     // console.log(await ctx.db.execute(sql))
    
//     let aa = `select * from quyu,quyu2 where quyu.quyu2Id=quyu2.id`
//     ctx.body = await ctx.db.execute(aa)
// }
// let getQuyu2 = async ctx=>{
//     let sql = `select * from quyu2 where quyu2.areaId=1`
//     ctx.body=await ctx.db.execute(sql)
// }     
// let getKucun = async ctx=>{
//     let sql = `select * from kucun`
//     ctx.body = await ctx.db.execute(sql)
//     console.log(sql);
// }
// let getCaipin = async ctx=>{
//     let sql = `select * from caipin`
//     ctx.body = await ctx.db.execute(sql)
//     console.log(sql);
// }
// let getHuiyuan = async ctx=>{
//     let sql = `select * from huiyuan`
//     ctx.body = await ctx.db.execute(sql)
//     console.log(sql);
// }

let getWenzhang = async ctx=>{
    let sql = `select * from texts`
    ctx.body = await ctx.db.execute(sql)
    console.log(sql);
}
let getXiangQing = async ctx=>{
    let sql = `select * from texts`
    ctx.body = await ctx.db.execute(sql)
    console.log(sql);
}

let getInfo2 = async ctx => {
    let {name } = ctx.query
    let sql = `select * from zt_user`;
    sql += ` where name='${name}'`
    let res = await ctx.db.execute(sql)
    if (res.length === 0) {
        ctx.status = 401
        ctx.body = {
            code: -1,
            msg: '获取用户信息失败'
        }
    } else {
        ctx.body = {
            code: 1,
            name: res[0].name,
            router_id: res[0].router_id,
        }
    }
}


module.exports = {
    // getUser,getQuyu,getKucun,getCaipin,getHuiyuan,getQuyu2,userInfo,
    // userInfo
    getWenzhang,getXiangQing,getInfo2
}